<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>项目款项-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<link rel="stylesheet" href="__PUBLIC__/mobile/css/dropload.css">
<link rel="stylesheet" href="__PUBLIC__/mobile/css/mobiscroll.min.css">
<style>
    .content{ padding-bottom: 54px; }
    .financial_list li table .not th{ padding-top: 0; }
    .btnbox{ text-align: center; }
    .btnbox .btn{ padding-top: 0; }
    .calendar_fix .btn a{ color: #ffa000; width: 28%; border: 1px solid #ffa000; }
</style>
</head>
<body style="background: #f3f3f3;">
<div class="header">
	<a href="__APP__/Mobile/Index/index" class="back_btn"></a>
    项目款项统计
    <a href="javascript:;" class="header_txt_btn project_search"></a>
</div>
<div class="select_menu">
    <div class="classify clearboth w3">
        <a class="a" href="javascript:;"><span><if condition="$center_id eq -10">所属中心<else />{$center_name}</if></span></a><a class="a" href="javascript:;"><span><if condition="$ptype eq -10">项目类型<else /><if condition="$ptype_name_length gt 4">{:msubstr($ptype_name,0,4)}<else />{$ptype_name}</if></if></span></a></a><a class="date" href="javascript:;"><span><b>起 {$start}<br>止 {$end}</b></span></a>
    </div>
    <div class="btn_box">
        <ul>
            <foreach name="pro_list" item="vo">
                <li <if condition="$center_id eq $vo['name2']">class="active"</if>>
                <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds_total/keyword/{$keyword}/center_id/{$vo['name2']}/ptype/{$ptype}/start/{$start}/end/{$end}">{$vo['name5']}</a>
                </li>
            </foreach>
        </ul>
        <ul>
            <li <if condition="$ptype eq -10">class="active"</if>>
            <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds_total/keyword/{$keyword}/center_id/{$center_id}/ptype/-10/start/{$start}/end/{$end}">项目类型</a>
            </li>
            <foreach name="ptype_list" item="vo">
                <li <if condition="$ptype eq $vo['id']">class="active"</if>>
                <a class="clear_storage" href="__APP__/Mobile/Financial/project_funds_total/keyword/{$keyword}/center_id/{$center_id}/ptype/{$vo['id']}/start/{$start}/end/{$end}">{$vo['second_name']}</a>
                </li>
            </foreach>
        </ul>
    </div>
</div>
<div class="content">
    <div class="financial_list">
        <ul>
            <foreach name="result" item="vo">
                <li>
                    <a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/{$vo['id']}/keyword/{$keyword}/center_id/{$center_id}/ptype/{$ptype}/start/{$start}/end/{$end}/form/total">
                        <span class="tit">{$vo['project_num']}  <i>|</i>  {$vo['p_typen']}</span>
                        <p>{$vo['project_name']}</p>
                        <table>
                            <tr>
                                <th>应开票金额</th>
                                <th>应开票日期</th>
                                <th>已开票金额</th>
                            </tr>
                            <tr>
                                <td>{$vo['yinkp']}</td>
                                <td>{$vo['ticket_date']}</td>
                                <td>{$vo['yikp']}</td>
                            </tr>
                            <tr class="not">
                                <th>剩余应开票金额</th>
                                <th>已收款金额</th>
                                <th>剩余应收款金额</th>
                            </tr>
                            <tr>
                                <td>{$vo['syykp']}</td>
                                <td>{$vo['yisk']}</td>
                                <td>{$vo['syysk']}</td>
                            </tr>
                        </table>
                        <div class="last">
                            合同金额  <em>{$vo['contract_money']}</em> <span>{$vo['add_user']}({$vo['add_date']|substr=0,10})</span>
                        </div>
                    </a>
                </li>
            </foreach>
        </ul>
    </div>
</div>
<if condition="$result neq NULL">
    <div class="funds_total">
        <table class="table" border="0" cellspacing="0">
            <tr>
                <td class="td1"><em>合计</em></td>
                <td><p><i>合同金额</i><span>{$sum['contract_money']}</span></p><p><i>已收款金额</i><span class="red">{$sum['yisk']}</span></p></td>
                <td class="td2"><div><em>明细</em><img src="__PUBLIC__/mobile/images/financial/arrow.png" alt=""></div></td>
            </tr>
        </table>
        <div class="funds_move">
            <h3>合计</h3>
            <table>
                <tr>
                    <th>合同金额</th>
                    <th>应开票金额</th>
                    <th>已开票金额</th>
                </tr>
                <tr>
                    <td>{$sum['contract_money']}</td>
                    <td>{$sum['yinkp']}</td>
                    <td class="red">{$sum['yikp']}</td>
                </tr>
                <tr>
                    <th>剩余应开票金额</th>
                    <th>已收款金额</th>
                    <th>剩余应收款金额</th>
                </tr>
                <tr>
                    <td>{$sum['syykp']}</td>
                    <td class="red">{$sum['yisk']}</td>
                    <td>{$sum['syysk']}</td>
                </tr>
            </table>
        </div>
    </div>
</if>
<div class="Mask item_mask"></div>
<div class="Mask Mask2 funm"></div>
<!-- 弹框 -->
<div class="search_fix">
    <div class="search_header">
        <a class="back_btn" href="javascript:;"></a>
        <input class="project_search_inp" type="text" value="{$keyword}" placeholder="输入搜索内容…">
        <a href="javascript:;" class="header_txt_btn jd_up active">搜索</a>
    </div>
    <div class="form_item">
        <div class="form_item_tit">
            搜索推荐
        </div>
        <div class="form_item_box search_btn_box">
			<if condition="$result_t eq ''">暂无相关内容</if>
			<foreach name="result_t" item="vo">
            <a href="__APP__/Mobile/Financial/project_funds_total/keyword/{$vo['keyword']}/center_id/{$center_id}/ptype/{$vo['id']}/start/{$start}/end/{$end}">{:msubstr($vo['keyword'],0,6,'utf-8',false)}</a>
			</foreach>
        </div>
        <div class="form_item_tit">
            搜索历史
        </div>
        <div class="form_item_box search_list_box">
            <if condition="$result_l eq ''">
                <p style="padding:7px 0">暂无相关内容</p>
            <else />
                <ul>
                    <foreach name="result_l" item="vo">
                    <li><a href="__APP__/Mobile/Financial/project_funds_total/keyword/{$vo['keyword']}/center_id/{$center_id}/ptype/{$vo['id']}/start/{$start}/end/{$end}">{$vo['keyword']}</a></li>
                    </foreach>
                </ul>
                <div class="clear">清空搜索历史</div>
            </if>
        </div>
    </div>
</div>
<!-- 弹出框 -->
<div class="calendar_fix">
    <a href="javascript:;" class="close"></a>
	<input type="hidden" value="{$start} - {$end}" id="fix_date">
	<div class="btnbox btn">
        <a class="clear_storage" href="{$last_url}" class="btn">上一周期</a>
        <a href="javascript:;" class="btn select_btn clear_storage">搜索</a>
        <a class="clear_storage" href="{$next_url}" class="btn">下一周期</a>
		<input name="hide" type="hidden" start="{$start}" end="{$end}">
	</div>
</div>
<include file="Include:javascript" />
<script src="__PUBLIC__/mobile/js/dropload.min.js"></script>
<script src="__PUBLIC__/mobile/js/mobiscroll.min.js"></script>
<script>
    //周期搜索
    $(".select_btn").click(function(){
        var start =  $("[name='hide']").attr('start'),
                end = $("[name='hide']").attr('end');
        window.location.href="__APP__/Mobile/Financial/project_funds_total/keyword/{$keyword}/center_id/{$center_id}/ptype/{$ptype}/start/"+start+"/end/"+end;
    });
    $('.select_menu .classify .a').each(function(i){
        var _this = $(this);
        _this.click(function(){
            if(_this.hasClass('active')){
                _this.removeClass('active');
                $('.select_menu ul').removeClass('active');
                $('.select_menu .btn_box').css('height','0');
                $('.item_mask').fadeOut();
            }else{
                var hei = $('.select_menu ul').eq(i).height()+20;
                _this.addClass('active').siblings().removeClass('active');
                $('.select_menu ul').eq(i).addClass('active').siblings().removeClass('active');
                $('.select_menu .btn_box').css('height',hei);
                $('.item_mask').fadeIn();
            }
        })
    })
    $('.funds_total .td2 div').click(function(){
        if($('.funds_total').hasClass('active')){
            $('.funm').stop(true,true).fadeOut(function(){
                $(this).addClass('Mask2')
            });
            $('.funds_total').removeClass('active')
        }else{
            $('.funm').stop(true,true).fadeIn().removeClass('Mask2');
            $('.funds_total').addClass('active')
        }
    })
    $('.funm').on('touchstart',function(){
        $('.funds_total').removeClass('active')
        $('.funm').fadeOut(function(){
            $(this).addClass('Mask2')
        });
    })
    //日期
    $(".date").click(function(){
        $(".calendar_fix").fadeIn();
        $('.Mask2').removeClass('funm').fadeIn();
        $('#fix_date').mobiscroll().range({
            theme: 'ios',
            lang: 'zh',
            display: 'inline',
            onSetDate: function (event, inst) {
                var dates = event.active;
                if(dates=="start"){
                    var start = formatDate(event.date);
                    $("[name='hide']").attr('start',start)
                }else{
                    var end = formatDate(event.date);
                    $("[name='hide']").attr('end',end)
                }
            }
        });
    })
    $(".calendar_fix .close").click(function(){
        $(".calendar_fix").fadeOut();
        $('.Mask2').addClass('funm').fadeOut();
    })
    $('.item_mask').on('touchstart',function(){
        $('.select_menu .classify a,.select_menu ul').removeClass('active');
        $('.select_menu .btn_box').css('height','0');
        $('.item_mask').fadeOut();
    })
    //搜索
    $('.project_search').click(function(){
        $('.search_fix').fadeIn();
        $('html').addClass('active');
    })
    $('.back_btn').click(function(){
        $('.search_fix').fadeOut();
        $('html').removeClass('active');
    })
    $('.project_search_inp').bind('propertychange input', function () {
        if($(this).val()!=''){
            $('.jd_up').removeClass('active');
        }else{
            $('.jd_up').addClass('active');
        }
    })
    $('.jd_up').click(function(){
        sessionStorage.clear();
        var val = $('.project_search_inp').val();
        location.href="__APP__/Mobile/Financial/project_funds_total/keyword/"+val+"/center_id/{$center_id}/ptype/{$ptype}/start/{$start}/end/{$end}";
    })
    $('.clear').click(function(){
        $.ajax({
            type: 'POST',
            async:false,
            dataType:"json",
            data:{"center_id":130010},
            url:"__APP__/Mobile/Project/project_funds_del",
            dataType: 'json',
            success: function(data){
                $('.search_list_box').html("<p style='padding:7px 0'>暂无相关内容</p>");
            }
        })
    })


    var center_id = "{$center_id}";
    $(".clear_storage,.project_menu,.search_btn_box a,.search_list_box a,.back_btn").click(function(){sessionStorage.clear();});

    $(function(){
        var $now = 1;
        //输出本地存储now
        var $storage_now = sessionStorage.getItem("storage_now");
        if($storage_now){
            $now = parseInt($storage_now);
        }
        var page = 3,
            $count = "{$count}",
            max = Math.ceil(parseInt($count)/page);

        $('.content').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                if($now<max){
                    var start = "{$start}",
                            end = "{$end}",
                            keyword = "{$keyword}",
                            center_id = "{$center_id}",
                            ptype = "{$ptype}",
                            html = '',
                            $start_count = page*$now;
                    $.ajax({
                        type: 'POST',
                        async:false,
				        dataType:"json",
                        data:{"start":start,"end":end,"keyword":keyword,"center_id":center_id,"ptype":ptype,"start_size":$start_count,"start_page":page},
                        url:"__APP__/Mobile/Financial/project_funds_total_ajax",
                        dataType: 'json',
                        success: function(data){
                            if(data){
                                for(var i=0; i<data.length; i++){
                                    html += '<li>';
                                    html += '<a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/'+data[i].id+'/keyword/{$keyword}/center_id/{$center_id}/ptype/{$ptype}/start/{$start}/end/{$end}/form/total">';
                                    html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                                    html += '<p>'+data[i].project_name+'</p>';
                                    html += '<table><tr><th>应开票金额</th><th>应开票日期</th><th>已开票金额</th></tr><tr>';
                                    html += '<td>'+data[i].yinkp+'</td>';
                                    html += '<td>'+data[i].ticket_date+'</td>';
                                    html += '<td>'+data[i].yikp+'</td>';
                                    html += '</tr><tr class="not"><th>剩余应开票金额</th><th>已收款金额</th><th>剩余应收款金额</th></tr><tr>';
                                    html += '<td>'+data[i].syykp+'</td>';
                                    html += '<td>'+data[i].yisk+'</td>';
                                    html += '<td>'+data[i].syysk+'</td>';
                                    html += '</tr></table><div class="last">';
                                    html += '合同金额  <em>'+data[i].contract_money+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                                    html += '</div></a>';
                                    html += '</li>';
                                }
                            }
                            $now++;
                            //保存本地存储
                            var $get_str_after = sessionStorage.getItem("storage_str"),
                                $storage_str = "";

                            if($get_str_after){
                                $storage_str += $get_str_after.replace(/^\[|\]$/g,"")+",";
                            }
                            $storage_str += JSON.stringify(data).replace(/^\[|\]$/g,"");
                            $storage_str = "["+$storage_str+"]";
                            sessionStorage.setItem("storage_str",$storage_str);
                            sessionStorage.setItem("storage_now",$now);
                            $('.financial_list ul').append(html);
                            me.resetload();
                        },
                        error: function(xhr, type){
                            alert('Ajax error!');
                            // 即使加载出错，也得重置
                            me.resetload();
                        }
                    });
                }else{
                    me.lock();
                    me.noData();
                    me.resetload();
                }
            }
            
        });
        
    })
    $(window).scroll(function(){
        //保存滚动条位置
        var $storage_top = $(window).scrollTop();
        sessionStorage.setItem("storage_top",$storage_top);
    });
    $(function(){
        var $get_str_before = sessionStorage.getItem("storage_str"),
            $storage_top = sessionStorage.getItem("storage_top");

        if($get_str_before){
            var data = JSON.parse($get_str_before),
				start = "{$start}",
                    end = "{$end}",
                    keyword = "{$keyword}",
                    center_id = "{$center_id}",
                    ptype = "{$ptype}",
                    html = '';
            for(var i=0; i<data.length; i++){
                html += '<li>';
                html += '<a href="__APP__/Mobile/Financial/project_funds_detail_xm/id/'+data[i].id+'/keyword/{$keyword}/center_id/{$center_id}/ptype/{$ptype}/start/{$start}/end/{$end}/form/total">';
                html += '<span class="tit">'+data[i].project_num+'  <i>|</i>  '+data[i].p_typen+'</span>';
                html += '<p>'+data[i].project_name+'</p>';
                html += '<table><tr><th>应开票金额</th><th>应开票日期</th><th>已开票金额</th></tr><tr>';
                html += '<td>'+data[i].yinkp+'</td>';
                html += '<td>'+data[i].ticket_date+'</td>';
                html += '<td>'+data[i].yikp+'</td>';
                html += '</tr><tr class="not"><th>剩余应开票金额</th><th>已收款金额</th><th>剩余应收款金额</th></tr><tr>';
                html += '<td>'+data[i].syykp+'</td>';
                html += '<td>'+data[i].yisk+'</td>';
                html += '<td>'+data[i].syysk+'</td>';
                html += '</tr></table><div class="last">';
                html += '合同金额  <em>'+data[i].contract_money+'</em> <span>'+data[i].add_user+'('+data[i].add_date.substring(0,10)+')</span>';
                html += '</div></a>';
                html += '</li>';
            }
            $('.financial_list ul').append(html);
        }

        if($storage_top){
            $(window).scrollTop($storage_top);
        }
    })
</script>
</body>
</html>